| Conditions | 2 | 
| Paths | 4 | 
| Total Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | import App from "app";  | 
            ||
| 11 | App.helpers.array.sortByObjectKey = (data, prop, direction = "asc") => { | 
            ||
| 12 |     if (["asc", "desc"].indexOf(direction) === -1) { | 
            ||
| 13 |         throw new Error("Direction should be asc or desc"); | 
            ||
| 14 | }  | 
            ||
| 15 | |||
| 16 |     return data.sort((a, b) => { | 
            ||
| 17 | let response = 0,  | 
            ||
| 18 | ap = a[prop],  | 
            ||
| 19 | bp = b[prop];  | 
            ||
| 20 | |||
| 21 |         if (ap < bp) { | 
            ||
| 22 | response = direction === "asc" ? -1 : 1;  | 
            ||
| 23 |         } else if (ap > bp) { | 
            ||
| 24 | response = direction === "asc" ? 1 : -1;  | 
            ||
| 25 | }  | 
            ||
| 26 | |||
| 27 | return response;  | 
            ||
| 28 | });  | 
            ||
| 29 | };  | 
            ||
| 30 | |||
| 48 |